/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.crm.slcm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Random;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author Yuwei nd Zhiqi
 */
@Entity
public class Address implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String addressType;
    private String addressLine1;
    private String addressLine2;
    private String zipCode;
    private String city;
    private String stateName;
    private String country;
    private Timestamp timeCreated;

    public Address(){
        addressType = "";
        addressLine1 = "";
        addressLine2 = "";
        zipCode = "";
        city = "";
        stateName = "";
        country = "";
        Random rand = new Random();
        long seed = new Date().getTime() + (long)rand.nextInt(10000);
        timeCreated = new Timestamp(seed);
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getAddressType() {
        return addressType;
    }

    public void setAddressType(String addressType) {
        this.addressType = addressType;
    }
    
    public String getAddressLine1() {
        return addressLine1;
    }

    public void setAddressLine1(String addressLine1) {
        this.addressLine1 = addressLine1;
    }

    public String getAddressLine2() {
        return addressLine2;
    }

    public void setAddressLine2(String addressLine2) {
        this.addressLine2 = addressLine2;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getStateName() {
        return stateName;
    }

    public void setStateName(String state) {
        this.stateName = state;
    }

    public String getZipCode() {
        return zipCode;
    }

    public void setZipCode(String zipCode) {
        this.zipCode = zipCode;
    }

    public Timestamp getTimeCreated() {
        return timeCreated;
    }

    public void setTimeCreated(Timestamp timeCreated) {
        this.timeCreated = timeCreated;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Address)) {
            return false;
        }
        Address other = (Address) object;
        
        // Compare timestamp
        if(!this.timeCreated.equals(other.timeCreated))
            return false;
        
        return true;
    }

    @Override
    public String toString() {
        return "merlion.crm.sopm.entity.Address[ id=" + id + " ]";
    }
    
}
